import {useLocation,useNavigate} from 'umi';
function Login(){
    //获取当前路径的location对象
    const location = useLocation();
    const navigate = useNavigate();
    const login = ()=>{
        //把isLogin=true保存到localStorage
        localStorage.setItem('isLogin','true');
        if(location.state && location.state.from){
            navigate(location.state.from);
        }else{
            navigate('/');
        }
    }
    return (
        <div>
            <button onClick={login}>登录</button>
        </div>
    )
}
export default Login;